package com.lsk.mytuan;

import java.util.Scanner;

public class UI {
    private static Scanner scanner = new Scanner(System.in);
    private static final int TITLE_CHARS = 30;

    private static void printSymbols (int times) {
        for (int i = 0; i < times; i++) {
            print("=");
        }
    }

    public static void printTitle (String content) {
        int totalSymbols = TITLE_CHARS - content.length();
        if (totalSymbols % 2 == 0) {
            printSymbols(totalSymbols / 2);
            print(content);
            printSymbols(totalSymbols / 2);
            println("");
        } else {
            int symbolsBefore = totalSymbols / 2;
            int symbolsAfter = symbolsBefore + 1;
            printSymbols(symbolsBefore);
            print(content);
            printSymbols(symbolsAfter);
            println("");
        }
    }

    public static void println(String str) {
        System.out.println(str);
    }

    public static void print(String str) {
        System.out.print(str);
    }

    public static String readString () {
        return scanner.next();
    }

    public static int readInt () {
        return scanner.nextInt();
    }

    public static float readFloat () {
        return scanner.nextFloat();
    }

    public static int welcomeInfo (String role) {
        printTitle("欢迎使用我的美团");
        switch (role) {
            case "guest":
                println("1.登陆");
                println("2.注册");
                println("3.退出");
                break;
            case "user":
                println("1.点餐");
                println("2.查看购物车");
                println("3.清空购物车");
                println("4.支付购物车");
                println("5.查看订单");
                println("6.删除订单");
                println("7.支付订单");
                println("8.签收订单");
                println("9.删除所有已签收订单");
                println("10.查看个人信息");
                println("11.更改个人信息");
                println("12.存款");
                println("13.登出");
                break;
            case "store":
                println("1.添加菜品");
                println("2.删除菜品");
                println("3.更改菜品");
                println("4.所有菜品");
                println("5.商家信息");
                println("6.更改密码");
                println("7.更改名称");
                println("8.登出");
                break;
        }
        return scanner.nextInt();
    }

    public static void printItemsTableHead() {
        println("ID      名称      单价     销量");
    }
    public static void printOrdersTableHead() {
        printTitle("ID     菜品      数量      总价       状态");
    }
}
